package com.ruoyi.web.controller.riskAssessment;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.riskAssessment.domain.RiskTrainScore;
import com.ruoyi.riskAssessment.service.IRiskTrainScoreService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 风险-培训管理-分数Controller
 *
 * @author lth
 * @date 2023-12-18
 */
@RestController
@RequestMapping("/riskAssessment/score")
public class RiskTrainScoreController extends BaseController
{
    @Autowired
    private IRiskTrainScoreService riskTrainScoreService;

    /**
     * 查询风险-培训管理-分数列表
     */
    @PreAuthorize("@ss.hasPermi('riskAssessment:score:list')")
    @GetMapping("/list")
    public TableDataInfo list(RiskTrainScore riskTrainScore)
    {
        startPage();
        List<RiskTrainScore> list = riskTrainScoreService.selectRiskTrainScoreList(riskTrainScore);
        return getDataTable(list);
    }

    /**
     * 导出风险-培训管理-分数列表
     */
    @PreAuthorize("@ss.hasPermi('riskAssessment:score:export')")
    @Log(title = "风险-培训管理-分数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RiskTrainScore riskTrainScore)
    {
        List<RiskTrainScore> list = riskTrainScoreService.selectRiskTrainScoreList(riskTrainScore);
        ExcelUtil<RiskTrainScore> util = new ExcelUtil<RiskTrainScore>(RiskTrainScore.class);
        util.exportExcel(response, list, "风险-培训管理-分数数据");
    }

    /**
     * 获取风险-培训管理-分数详细信息
     */
    @PreAuthorize("@ss.hasPermi('riskAssessment:score:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(riskTrainScoreService.selectRiskTrainScoreById(id));
    }

    /**
     * 新增风险-培训管理-分数
     */
    @PreAuthorize("@ss.hasPermi('riskAssessment:score:add')")
    @Log(title = "风险-培训管理-分数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RiskTrainScore riskTrainScore)
    {
        return toAjax(riskTrainScoreService.insertRiskTrainScore(riskTrainScore));
    }

    /**
     * 修改风险-培训管理-分数
     */
    @PreAuthorize("@ss.hasPermi('riskAssessment:score:edit')")
    @Log(title = "风险-培训管理-分数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RiskTrainScore riskTrainScore)
    {
        return toAjax(riskTrainScoreService.updateRiskTrainScore(riskTrainScore));
    }

    /**
     * 删除风险-培训管理-分数
     */
    @PreAuthorize("@ss.hasPermi('riskAssessment:score:remove')")
    @Log(title = "风险-培训管理-分数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(riskTrainScoreService.deleteRiskTrainScoreByIds(ids));
    }
}
